<!DOCTYPE html>
<head>
    <title>{$site_seo_title} {$site_name}</title>
    {include file="public:head" /}
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/timeline/jquery.eeyellow.Timeline.css"/>
    <meta name="description" content="{$site_seo_description}">
</head>
<body>
<div class="about_header">
    <div class="container">
        <!---start-top-nav---->
        <div class="top-nav">
            <div class="top-header">
                <div class="logo">
                    <a href="/index.html"><img src="{$wjf_theme_path}public/images/logo.png" alt=""/></a>
                </div>
            </div>
            {include file="public:nav" /}
            <script type="text/javascript">
                $(document).ready(function () {

                    $('#menu-toggle').click(function () {
                        $('#menu').toggleClass('open');
                        e.preventDefault();
                    });

                });
            </script>
        </div>
        <!---End-top-nav---->
    </div>
</div>
<div class="profile-info">
    <div class="container">
        <div class="about_grid1">
            <div class="col-md-8 box">
                <div class="VivaTimeline">
                    <dl id="art_news">

                    </dl>
                    <div class="more-article text-center"><a href="javascript:;">加载更多</a>
                        <input type="hidden" id="pageid" value="1">
                    </div>
                </div>
            </div>
            {include file="public:rightslider" /}
        </div>
    </div>
</div>
{include file="public:footer" /}
{include file="public:scripts" /}
<script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/timeline/jquery.eeyellow.Timeline.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.VivaTimeline').vivaTimeline({
            carousel: true,
            carouselTime: 3000
        });
    });
</script>
<script type="text/javascript">
    $(function () {
        ajaxPost();
        $('.more-article').click(function () {
            ajaxPost();
        });

        //ajax请求函数
        function ajaxPost() {
            var p = $('#pageid').val();
            console.log(p);
            var s = '';
            $.ajax({
                type: 'post',
                url: '/index/article/ajaxNews',
                data: {page: p},
                dataType: 'json',
                success: function (data) {
                    console.log(data['code']);
                    $('#pageid').val(parseInt(p)+1);
                    if(data['code'] === 1){
                        $.each(data['0']['data'], function (key, val) {
                            var k = parseInt(key);
                            s += '<dd class="pos-' + place(k) + ' clearfix">';
                            s += '<div class="circ"></div>';
                            s += ' <div class="time">' + getCurrentDate(val.news_time, 2) + '</div>';
                            s += '<div class="events">';
                            s += '<div class="events-header">' + val.news_title + '</div>';
                            s += '<a href="/index/article/info/id/'+val.n_id+'.html">';
                            s += '<div class="events-body">';
                            s += '<div class="row" style="display: block;">';
                            s += '<div class="col-md-6 pull-left">';
                            s += '<img class="events-object img-responsive img-rounded" src="' + imgShow(val.news_img) + '" />';
                            s += '</div>';
                            s += '<div class="events-desc">';
                            s += val.news_scontent;
                            s += '</div>';
                            s += '</div>';
                            s += '</div>';
                            s += '</a>';
                            s += '<div class="events-footer">';
                            s += '<span style="color:#575757;font-size: 14px;">' + getCurrentDate(val.news_time, 1) + '  By  ' + val.news_source + '</span>&nbsp;&nbsp;';
                            s += '</div>';
                            s += '</div>';
                            s += '</dd>';
                        });
                        $("#art_news").append(s);
                        s = '';
                    }else{
                        $(".more-article").remove();
                    }
                },
            });
        };

        function place(key) {
            var position = '';
            if (key % 2 == 0) {
                position = 'left';
            } else {
                position = 'right';
            }
            return position;
        }

        function imgShow(str) {
            if (str === null || str === undefined || str === '') {
                str = '__PUBLIC__/img/news.jpg';
            }
            return str;
        }

        function getCurrentDate(sn, num) {
            var date = new Date(parseInt(sn) * 1000);
            var monthArray = new Array
            ("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug",
                "Sept", "Oct", "Nov", "dec");
            month = date.getMonth();
            day = date.getDate();
            if (day.toString().length == 1) {
                day = "0" + day.toString();
            }
            //document.write(monthArray[month]+" "+day+", "+date.getFullYear());
            if (num === 1) {
                return monthArray[month] + " " + day + ", " + date.getFullYear();
            }
            return monthArray[month] + " " + day;
        }
    });

</script>
</body>
</html>